import React, { useRef } from 'react';
import * as Actions from '../store/action/todo' 
import {connect} from '../react-redux'
import {bindActionCreators} from 'redux'
const Add = (props) => {
  const inputRef = useRef()
  const addNewTool = () => {
    props.addNewToDo(inputRef.current.value)
  }
  return (
    <>
      <input ref={inputRef} />
      <button onClick={addNewTool}>添加</button>
    </>
  )
}
// export default Add

export default connect(
  (state,ownProps)=>{
    return state.todo
  },
  (dispatch,ownProps)=>{
    const actions = bindActionCreators(Actions, dispatch);
    return actions
  },
  (stateProps, dispatchProps, ownProps)=>{
    return {...stateProps,...dispatchProps,...ownProps}
  }
)(Add)